# Maintainer: David Ventura <david@davidv.dev>
pkgname=wk-adblock
pkgver=0.0.4
_commit=665ffb4126ae924e345d04adcf6242066216a508
pkgrel=3
pkgdesc="Simple ad-blocker for Webkit2 Webview"
options="!check" # No testsuite
url="https://github.com/DavidVentura/webextension-adblocker/"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le" # limited by rust
license="GPL-3.0-or-later"
makedepends="cargo clang-dev glib-dev llvm-dev webkit2gtk-dev"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://codeload.github.com/DavidVentura/webextension-adblocker/tar.gz/$_commit
	cargo-lock.patch
	"
builddir="$srcdir/webextension-adblocker-$_commit"

# optimise size
export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_PANIC="abort"
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"
export CARGO_FEATURE_USE_SYSTEM_LIBS=1


prepare() {
	default_prepare

	cd wk-we-adblock
	cargo fetch --locked
}

build() {
	cd wk-we-adblock
	cargo build --release --frozen
}

package() {
	make install DESTDIR="$pkgdir"
	install -Dm644 manpage "$pkgdir"/usr/share/man/man1/$pkgname.1
}

sha512sums="
a2d1b36e364311c9e14849ee76628d0e1d1964b5f5b9ba4a3a4211ec798080d1ff97ce0c08bc708114e3ed6a40a7ef437406280e61a880340d691c5a5d0712b3  wk-adblock-0.0.4.tar.gz
1808c2b078a29ee26a1f45818a81e11de0c5180efba0643e1d6c686d702dbf9dbff4b112f75a3e6ee1747887731ab3ecb892993e9bcca8975e107f63bc9f6661  cargo-lock.patch
"
